home *** CD-ROM | disk | FTP | other *** search
- { ircle - Internet Relay Chat client }
- { File: ircle }
- { Copyright ⌐ 1992 Olaf Titz (s_titz@iravcl.ira.uka.de) }
-
- { This program is free software; you can redistribute it and/or modify }
- { it under the terms of the GNU General Public License as published by }
- { the Free Software Foundation; either version 2 of the License, or }
- { (at your option) any later version. }
-
- { This program is distributed in the hope that it will be useful, }
- { but WITHOUT ANY WARRANTY; without even the implied warranty of }
- { MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the }
- { GNU General Public License for more details. }
-
- { You should have received a copy of the GNU General Public License }
- { along with this program; if not, write to the Free Software }
- { Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. }
-
- program ircle;
- { This is a small IRC client for the Macintosh. }
- { Written by Olaf Titz (s_titz@iravcl.ira.uka.de), Karlsruhe, July/August 1992. }
- { The TCP interface code written by Peter N.Lewis and Harry Chesley/Apple Computer Inc. }
- { Parts of the command protocol handling, and many ideas }
- { derived from IRCII by Michael Sandrof }
-
- uses
- TCPTypes, TCPStuff, TCPConnections,{}
- Coroutines, ApplBase, MsgWindows, InputLine, {}
- IRCGlobals, IRCaux, IRCPreferences, IRCInput, {}
- IRCCommands, IRCChannels, IRCSComm, IRCHelp, IRCInit;
-
- var
- i: integer;
- fmem, lofmem, t0: longint;
- purged: boolean;
- FMenu: MenuHandle;
-
- function Clock (var e: EventRecord): boolean;
- begin
- if abs(e.when - t0) >= 60 then begin
- t0 := e.when;
- UpdateStatusLine
- end;
- Clock := false
- end;
-
-
- { CheckMem gets called once in each run through the main event loop. }
- { If free memory runs low, first memory is compacted, then an alert is displayed }
- { and subsequent memory checking disabled for 30 seconds, or until more memory gets freed, }
- { e.g. by closing a window. }
- procedure CheckMem;
- var
- i: longint;
- begin
- if fmem < 0 then begin
- getdatetime(i);
- if (abs(i - lofmem) > MEMTIME) or (freemem > HIFREEMEM) then
- fmem := LOFREEMEM;
- end
- else if freemem < fmem then begin
- if purged then begin
- fmem := -1;
- getdatetime(lofmem);
- i := Alert(A_LOWMEM, nil)
- end
- else begin
- PurgeMem(maxSize);
- purged := true
- end
- end
- else
- purged := false;
- end;
-
- procedure ExitTCP;
- var
- i: integer;
- begin
- if logging then
- close(logfile);
- FinishEverything
- end;
-
- begin
- serverStatus := -1;
- fmem := LOFREEMEM;
- purged := false;
- if InitConnections('') <> noErr then
- i := Alert(A_TCPERR, nil)
- else begin
- IRCInitAll;
- i := ApplTask(@Clock, nullEvent);
- ApplExitproc(@ExitTCP);
- UnloadSeg(@IRCInitAll);
- t0 := -maxlongint;
- FMenu := GetMHandle(fileMenu);
- repeat
- CheckMem;
- if serverStatus = 0 then
- DisableItem(FMenu, M_F_OPEN)
- else
- EnableItem(FMenu, M_F_OPEN);
- if GetWRefCon(FrontWindow) = 0 then
- DisableItem(FMenu, M_F_CLOSE)
- else
- EnableItem(FMenu, M_F_CLOSE);
- ApplRun;
- until QuitRequest;
- ApplExit
- end;
- end.